package Offer.offer2017;

/**
 * 不用加减乘除做加法
 * Created by 雷文康 on 2018/1/6.
 */
public class Test47 {
    public static void main(String[] args) {
        System.out.println(sum(-8, -2));
    }
    public static int sum(int num1, int num2) {
        while (num2 != 0) {
            int sum = num1 ^ num2;
            int carry = (num1 & num2) << 1;
            num1 = sum;
            num2 = carry;
        }
        return num1;
    }
}
